Data management/Exploration & description

We can use GenStat to calculate the total lactation yield (TOTYLD) and the total yield to 210 days (YLD210). We use records M1-M15 to calculate YLD210 for cows with lactations ≥ 210 days but use the TOTYLD instead for YLD210 for cows with lactations < 210 days. Sometimes fewer than 15 milk offtakes were recorded for cows that lactated longer than 210 days. This needs to be taken into account in the calculations. The calculations as shown can be copied into a GenStat Input file (File → New... and click ' Text Window'). These lines can be executed by selecting them and then using Run Submit Selection.

"Calculate number of recorded milk offtakes. Result of MI.NE.0 is 1 if MI>0 and 0 if MI=0"
CALCULATE NTOT=(M1.NE.0)+(M2.NE.0)+(M3.NE.0)+(M4.NE.0)+(M5.NE.0)+(M6.NE.0)+ (M7.NE.0)+\
(M8.NE.0)+(M9.NE.0)+(M10.NE.0)+(M11.NE.0)+(M12.NE.0)+(M13.NE.0)+ M14.NE.0)+(M15.NE.0)+\
(M16.NE.0)+(M17.NE.0)+(M18.NE.0)
"Calculate total yield. Zeros at end of MI list do not affect calculation of total yield"
CALCULATE TOTYLD =(M1+M2+M3+M4+M5+M6+M7+M8+M9+M10+M11+M12+M13+M14+ M15\
+M16+M17+M18)/NTOT*LACLEN
"Calculate number of recorded yields up to 210 (=15x14) days" 
CALCULATE N210 = (M1.NE.0)+(M2.NE.0)+(M3.NE.0)+(M4.NE.0)+(M5.NE.0)+(M6.NE.0)+ (M7.NE.0)+\
M8.NE.0)+(M9.NE.0)+(M10.NE.0)+(M11.NE.0)+(M12.NE.0)+(M13.NE.0)+(M14.NE.0)+(M15.NE.0)
"Calculate total yield up to day 210"
CALCULATE YLD210=(M1+M2+M3+M4+M5+M6+M7+M8+M9+M10+M11+M12+M13+ M14+M15)\
/N210*210
"Recalculate YLD210 and put to TOTYLD if LACLEN<210. Result of LACLEN.LT.210 is 1 if lactation\
length < 210 or 0 otherwise"

CALCULATE YLD210=TOTYLD*(LACLEN.LT.210)+YLD210*(LACLEN.GE.210)
"Store results in spreadsheet; SHEET=0 implies current spreadsheet open"
FSPREADSHEET [SHEET=0; METHOD=replace] NTOT,TOTYLD,N210,YLD210